<template>
  <view>
    <!-- 顶部占位 -->
    <!-- #ifdef APP-PLUS -->
    <!-- <view-navbar></view-navbar> -->
    <!-- #endif -->
    <!-- 首行 -->
    <view class="h44 flex-cen margin" style="justify-content: flex-end">
      <view class="flex">
        <image
          @click="qrcodeHandle()"
          src="/static/img/my/01-saoma.png"
          alt=""
          style="margin-right: 30rpx; width: 40rpx; height: 40rpx"
        />
        <image
          @click="$pub.go('/pages_my/setting/setting')"
          src="/static/img/my/02-shezi.png"
          alt=""
          style="width: 40rpx; height: 40rpx"
        />
      </view>
    </view>

    <!-- 头像 -->
    <view class="margin ms13">
      <view class="">
        <view class="flex-between">
          <view class="mt10 flex-align">
            <!-- 						<u-avatar @click="$pub.go('/pages/my/myMsg/myMsg')"
							:src="userInfo.avatar || '/static/img/my/03-touxiang.png'" size="60" shape=""></u-avatar> -->
            <u-avatar
              @click="$pub.go('/pages_my/myMsg/myMsg')"
              :src="userImage"
              size="60"
              shape=""
            ></u-avatar>
            <view class="" style="margin-right: 184rpx; margin-left: 26rpx">
              <view class="flexflex ms10">
                <view class="size_17 text-bold">
                  {{ userInfo.unickname }}
                </view>
              </view>
              <u-button
                icon="edit-pen"
                v-if="sign == true"
                @click="signHandle"
                type="info"
                size="large"
                plain
                text="未签"
              ></u-button>
              <u-button
                icon="checkmark"
                v-else-if="sign == false"
                @click="signHandle"
                type="primary"
                size="large"
                plain
                text="已签"
              ></u-button>
            </view>
          </view>
          <view
            class="text-center flexflex flex-column flex-align"
            style="flex-wrap: nowrap"
            @click="$pub.go('/pages_my/healthCard/healthCard')"
          >
            <image
              class="ms10 mt13"
              src="/static/img/my/04-erweima.png"
              alt=""
              style="width: 60rpx; height: 60rpx"
            />
            <view class="size_14"> 健康卡 </view>
          </view>
          <view
            class="text-center flexflex flex-column flex-align"
            style="flex-wrap: nowrap"
            @click="preImg"
          >
            <image
              class="ms10 mt13"
              src="/static/img/my/04-erweima.png"
              alt=""
              style="width: 60rpx; height: 60rpx"
            />
            <view class="size_14"> 医保卡 </view>
          </view>
        </view>
      </view>
    </view>
    <!-- banner -->
    <view class="margin" style="margin-bottom: 18rpx" @click="quanyi">
      <image
        src="http://storage.dezhoucloud.com/img/my/05-card.png"
        alt=""
        style="height: 108rpx"
      />
    </view>
    <!-- 我的订单 -->
    <view class="margin bg_fff">
      <view
        style="
          display: flex;
          justify-items: center;
          align-items: center;
          padding-top: 30rpx;
          padding-bottom: 40rpx;
        "
      >
        <view class="left-line ml10 mr10"></view>
        <h4 class="size_17" style="margin-right: 360rpx">我的订单</h4>
        <text @click="goOrdercate()">全部订单</text>
        <u-icon name="arrow-right" @click="goOrdercate()"></u-icon>

        <!-- 原本代码跳转 -->
        <!-- <u-icon name="arrow-right" @click="$pub.go('/pages/my/ordercate/ordercate?type=0')"></u-icon> -->
      </view>
      <!-- list -->
      <view class="flex1">
        <view
          class="item flex_row1"
          v-for="(item, index) in statusList"
          :key="index"
          @click="
            $pub.go(
              `/pages_my/ordercate/ordercate?type=${encodeURIComponent(
                JSON.stringify(index + 1)
              )}`
            )
          "
        >
          <image
            :src="item.url"
            alt=""
            style="height: 46rpx; width: 46rpx"
          ></image>
          <text>{{ item.name }}</text>
        </view>
      </view>
      <!-- 医疗服务 -->
      <view class="bg_fff">
        <view
          style="
            display: flex;
            justify-items: center;
            align-items: center;
            padding-top: 30rpx;
            padding-bottom: 40rpx;
          "
        >
          <view class="left-line ml10 mr10"></view>
          <h4 class="size_17">医疗服务</h4>
        </view>
        <!-- list -->
        <view class="flex" style="flex-wrap: wrap">
          <view
            class="item1 flex_row1"
            v-for="(item, index) in serverList"
            :key="index"
            @click="$pub.go(item.dataUrl)"
          >
            <image
              :src="item.url"
              alt=""
              style="height: 46rpx; width: 46rpx"
            ></image>
            <text>{{ item.name }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { mapState, mapActions, mapMutations } from "vuex";
export default {
  data() {
    return {
      userData: null,
      sign: true,
      userImage: null,
      statusList: [
        {
          name: "待付款",
          url: "/static/img/my/06-bag.png",
        },
        {
          name: "待发货",
          url: "/static/img/my/07-fahuo.png",
        },
        {
          name: "待收货",
          url: "/static/img/my/08-souhuo.png",
        },
        {
          name: "已完成",
          url: "/static/img/my/09-wanchen.png",
        },
        {
          name: "退款/售后",
          url: "/static/img/my/10-tuikuan.png",
        },
      ],
      serverList: [
        {
          // name: "我的问诊",
          name: "问诊订单",
          url: "/static/img/my/11-wenzen.png",
          dataUrl: "/pages_my/myConsultation/myConsultation",
        },
        {
          name: "我的问诊",
          url: "/static/img/my/12-yishen.png",
          dataUrl: "/pages_my/myDoctor/myDoctor",
        },
        {
          name: "关注医生",
          url: "/static/img/my/13-guanzu.png",
          dataUrl: "/pages_my/payDoctor/payDoctor",
        },
        // {
        // 	name: "家庭医生",
        // 	url: "/static/img/my/14-jiating.png",
        // 	dataUrl: "/pages/familyDoctor/familyDoctor",
        // },
        {
          name: "我的积分",
          url: "/static/img/my/15-bingli.png",
          dataUrl: "/pages_my/myPoints/myPoints",
        },
        // {
        // 	name: "我的病历",
        // 	url: "/static/img/my/15-bingli.png",
        // 	dataUrl: '/pages/myCase/myCase'
        // },
        // {
        // 	name: "我的咨询",
        // 	url: "/static/img/my/16-zixun.png",
        // 	dataUrl: '/pages/my/zixun/zixun'
        // },
        {
          name: "我的处方",
          url: "/static/img/my/17-cufang.png",
          dataUrl: "/pages_my/myPrescription/myPrescription",
        },
        // {
        // 	name: "我的预约",
        // 	url: "/static/img/my/18-yuyue.png",
        // 	dataUrl: '/pages/my/yuyue/yuyue'
        // },
        {
          name: "我的家人",
          url: "/static/img/my/19-jiaren.png",
          dataUrl: "/pages_my/myFamily/myFamily",
        },
        {
          name: "健康档案",
          url: "/static/img/my/20-dangan.png",
          dataUrl: "/pages_my/dangan/dangan",
        },
        {
          name: "地址管理",
          url: "/static/img/my/21-dizi.png",
          dataUrl: "/pages_my/myAddress/myAddress",
        },
        // {
        // 	name: "客服中心",
        // 	url: "/static/img/my/22-kefu.png"
        // },
        // {
        // 	name: "问题反馈",
        // 	url: "/static/img/my/23-wenti.png"
        // },
      ],
    };
  },
  computed: {
    ...mapState("m_userInfo", ["userInfo"]),
    message() {
      return uni.getStorageSync("userInfo");
    },
  },
  onLoad() {},
  onShow() {
    this.checkinIn();
    this.userData = this.userInfo;
    this.userImage = this.userInfo.avatar;
  },
  methods: {
    quanyi() {
      uni.showToast({
        title: "敬请期待",
        icon: "none",
      });
    },
    goOrdercate() {
      uni.showToast({
        title: "敬请期待",
        icon: "none",
      });

      // this.$pub.go('/pages/my/ordercate/ordercate?type=0')
    },
    preImg(indexx, urlss) {
      let index = 1;
      let urls = [
        "https://img2.baidu.com/it/u=2499112433,1406976051&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
      ];
      console.log(urls, "preImg");
      uni.previewImage({
        current: index, //预览图片的下标
        urls: urls, //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
      });
    },
    async checkinPoints(e) {
      console.log("点击发起签到");
      let re = await this.$API.poitnsApi.checkinPoints({
        userId: this.message.userid,
      });
      // this.sign = re
    },
    async checkinIn(e) {
      console.log("是否签到");
      let re = await this.$API.poitnsApi.checkinIn({
        userId: this.message.userid,
      });
      /* 
				 未签到 true
				 签到 false
				 */
      this.sign = re;
    },
    signHandle() {
      this.checkinPoints();
      this.checkinIn();
	  
	  // #ifdef APP
		this.$router.go(0);
	  // #endif
	  // #ifdef MP
	  uni.reLaunch({
	  	url:'/pages/my/my'
	  })
	  // #endif

    },
    qrcodeHandle() {
      uni.scanCode({
        success: function (res) {
          console.log("条码类型：" + res.scanType);
          console.log("条码内容：" + res.result);
        },
      });
    },
  },
};
</script>

<style lang="scss">
page {
  // background-color: #f5f5f5;
  background-color: #fff;
}

.item1 {
  width: 25%;
  text-align: center;
  margin-bottom: 48rpx;
}

.flex1 {
  display: flex;
  justify-content: space-around;
}

.flex_row1 {
  text {
    margin-top: 12rpx;
  }

  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  align-content: flex-start;
  margin-bottom: 44rpx;
}
</style>